function cv = fix_b_asymptotic_cv(b, p)
%FIX_B_ASYMPTOTIC_CV Fixed-b asymptotic critical value
%   Calculates the fixed-b asymptotic critical value based on the choice of b 
%   (bandwidth parameter) and p (percentage point). Values are based on Table 1
%   from Kiefer and Vogelsang (2005), Econometric Theory.

% Input Validation (Optional but Recommended)
arguments
    b (1,1) double {mustBePositive}   % Ensure b is a positive scalar
    p (1,1) double {mustBeInRange(p, 0, 1)}  % Ensure p is a valid probability
end

% Critical Value Look-up Table
normal_cv = icdf('Normal', p, 0, 1); % Standard normal critical value
table_data = [
    normal_cv, 1.3040, 0.5135, -0.3386;
    normal_cv, 2.1859, 0.3142, -0.3427;
    normal_cv, 2.9694, 0.4160, -0.5324;
    normal_cv, 4.1618, 0.5368, -0.9060;
];

% Find Corresponding Row
if p == 0.9
    row_idx = 1;
elseif p == 0.95
    row_idx = 2;
elseif p == 0.975
    row_idx = 3;
elseif p == 0.99
    row_idx = 4;
else
    error('Invalid percentage point (p). Choose from 0.9, 0.95, 0.975, or 0.99.');
end

% Calculation with Vectorized Operations
b_powers = [1, b, b^2, b^3];  
cv = table_data(row_idx, :) * b_powers';
end
